package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.ConstructionChange;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/mapper/ConstructionChangeMapper.class */
public interface ConstructionChangeMapper {
    @Results(id = "map", value = {@Result(property = "assetsIds", column = "assets_ids"), @Result(property = "startTime", column = "start_time"), @Result(property = "endTime", column = "end_time"), @Result(property = "handWay", column = "hand_way"), @Result(property = "flowNo", column = "flow_no"), @Result(property = "appStatus", column = "app_status"), @Result(property = "rehabilitationTime", column = "rehabilitation_time")})
    @Select({"select cc.*,af.app_status,af.approval_steps_id as approvalStepsId  from  construction_change cc left join audit_flow af on cc.flow_no = af.flow_no where cc.id = #{id}"})
    ConstructionChange queryById(Integer num);

    @ResultMap({"map"})
    @Select({"<script>select * from construction_change cc left join audit_flow af on cc.flow_no = af.flow_no left join user u on cc.user_id = u.id <where> <if test='userId != null'>and af.applicant=#{userId} </if><if test='handWay != null '>and hand_way=#{handWay} </if><if test='unit != null and unit.length() &gt; 0'>and unit=#{unit} </if><if test='status != null'>and af.app_status = #{status} </if><if test='rehabilitation != null'>and cc.rehabilitation = #{rehabilitation} </if></where> </script>"})
    List<ConstructionChange> queryAll(@Param("userId") Integer num, @Param("status") Integer num2, @Param("handWay") Integer num3, @Param("unit") String str, @Param("rehabilitation") Integer num4);

    @ResultMap({"map"})
    @Select({"<script>select cc.*,af.*,u.id as userId,u.name as userName  from construction_change cc left join audit_flow af on cc.flow_no = af.flow_no left join user u on cc.user_id = u.id <where> <if test='unit != null and unit.length() &gt; 0'>unit like concat('%',#{unit},'%')  </if><if test='handWay != null '>and hand_way=#{handWay} </if><if test='userId != null '>and af.applicant=#{userId} </if><if test='status != null'>and af.app_status = #{status} </if></where> </script>"})
    List<ConstructionChange> queryStatistical(@Param("userId") Integer num, @Param("status") Integer num2, @Param("handWay") Integer num3, @Param("unit") String str);

    @Insert({"insert into construction_change(assets_ids,unit,start_time,end_time,content,director,contact,hand_way,user_id,flow_no) values(#{assetsIds},#{unit},#{startTime},#{endTime},#{content},#{director},#{contact},#{handWay},#{userId},#{flowNo})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(ConstructionChange constructionChange);

    @Update({"<script>update construction_change <set><if test='assetsIds != null and assetsIds.length &gt; 0'> assets_ids=#{assetsIds},</if><if test='unit != null and unit.length &gt; 0'> unit=#{unit},</if><if test='startTime != null and startTime.length &gt; 0'> start_time=#{startTime},</if><if test='endTime != null and endTime.length &gt; 0'> end_time=#{endTime},</if><if test='content != null and content.length &gt; 0'> content=#{content},</if><if test='director != null and director.length &gt; 0'> director=#{director},</if><if test='contact != null and contact.length &gt; 0'> contact=#{contact},</if><if test='handWay != null '> hand_way=#{handWay},</if><if test='userId != null '> user_id=#{userId},</if><if test='rehabilitation != null '> rehabilitation=#{rehabilitation},</if><if test='rehabilitationTime != null and rehabilitationTime.length &gt; 0'> rehabilitation_time=#{rehabilitationTime}</if></set> where id = #{id}</script>"})
    int update(ConstructionChange constructionChange);

    @Delete({"delete from construction_change where id = #{id}"})
    int deleteById(Integer num);
}